<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui">
<ui:composition template="../../WEB-INF/templates/UserTemplate.xhtml">
	<ui:define name="content">
			<h:form id="messages">
				<p:messages globalOnly="true" />
				<p:poll interval="1" listener="#{chat.checkNewMessages}" update="messages" />
				
				<ui:repeat var="msg" value="#{chat.chatMessages}">
					<p:panel header="#{msg.employee.empFirstname}" footer="#{msg.mesSendTime}">  
		        		<h:outputText value="#{msg.mesContent}" />  
		    		</p:panel>  
				</ui:repeat>
			</h:form>
			
			
			<h:form id="form">
				<p:messages id="msgs" />
				
				<h:outputLabel for="sentMsg" value="Message: " />
				<p:inputText id="sentMsg" value="#{chat.sentMessage.message}" label="sentMsg" required="true" />
				
				<p:commandButton id="btn" value="Envoyer le message" update="form" action="#{chat.sendMsg}" />
			</h:form>  
		</ui:define>
</ui:composition>
</html>